--- local.orig	2020-11-18 14:42:43.540055680 +0530
+++ local	2020-11-18 20:15:48.687164540 +0530
@@ -1,5 +1,4 @@
 # Local filesystem mounting			-*- shell-script -*-
-
 local_top()
 {
 	if [ "${local_top_used}" != "yes" ]; then
@@ -152,36 +151,70 @@
 	DEV="${real_dev}"
 }
 
-local_mount_root()
+local_find_by_uuid()
 {
-	local_top
-	if [ -z "${ROOT}" ]; then
-		panic "No root device specified. Boot arguments must include a root= parameter."
-	fi
-	local_device_setup "${ROOT}" "root file system"
-	ROOT="${DEV}"
+	partitions="$1"
 
-	# Get the root filesystem type if not set
-	if [ -z "${ROOTFSTYPE}" ] || [ "${ROOTFSTYPE}" = auto ]; then
-		FSTYPE=$(get_fstype "${ROOT}")
-	else
-		FSTYPE=${ROOTFSTYPE}
-	fi
+	for part in $partitions; do
+		if [ "$(blkid -p ${part} --match-types novfat -s USAGE -o value)" = "filesystem" ]; then
+			local_device_setup "${part}" "root file system"
+			ROOT="${DEV}"
+
+			# Get the root filesystem type if not set
+			if [ -z "${ROOTFSTYPE}" ] || [ "${ROOTFSTYPE}" = auto ]; then
+				FSTYPE=$(get_fstype "${ROOT}")
+			else
+				FSTYPE=${ROOTFSTYPE}
+			fi
 
-	local_premount
+			local_premount
 
-	if [ "${readonly?}" = "y" ]; then
-		roflag=-r
-	else
-		roflag=-w
-	fi
+			if [ "${readonly?}" = "y" ]; then
+				roflag=-r
+			else
+				roflag=-w
+			fi
+			checkfs "${ROOT}" root "${FSTYPE}"
 
-	checkfs "${ROOT}" root "${FSTYPE}"
+			# Mount root
+			# shellcheck disable=SC2086
+			if mount ${roflag} ${FSTYPE:+-t "${FSTYPE}"} ${ROOTFLAGS} "${ROOT}" "${rootmnt?}"; then
+				if [ -e "${rootmnt?}"/etc/os-release ]; then
+				image_uuid=$(sed -n 's/^IMAGE_UUID=//p' "${rootmnt?}"/etc/os-release | tr -d '"' )
+					if [ "${INITRAMFS_IMAGE_UUID}" = "${image_uuid}" ]; then
+						return 0
+					fi
+				fi
+				umount "${rootmnt?}"
+			fi
+		fi
+	done
+	return 1
+}
 
-	# Mount root
-	# shellcheck disable=SC2086
-	if ! mount ${roflag} ${FSTYPE:+-t "${FSTYPE}"} ${ROOTFLAGS} "${ROOT}" "${rootmnt?}"; then
-		panic "Failed to mount ${ROOT} as root file system."
+local_mount_root()
+{
+	local_top
+	if [ ! -e /conf/image_uuid ]; then
+		 panic "could not find image_uuid to select correct root file system"
+	fi
+	local INITRAMFS_IMAGE_UUID=$(cat /conf/image_uuid)
+	local partitions=""
+	local ret=1
+	local timeout_uuid=0
+	while [ "${ret}" != 0 ] && [ "${timeout_uuid}" -le 10 ]; do
+		wait_for_udev 10
+		partitions=$(blkid -o device)
+		local_find_by_uuid "$partitions"
+		ret=$?
+		timeout_uuid="$(cat /proc/uptime)"
+		timeout_uuid="${timeout_uuid%%[. ]*}"
+		timeout_uuid=$((timeout_uuid - local_top_time))
+	done
+	if [ "${ret}" != 0 ]; then
+		panic "Could not find ROOTFS with matching UUID $INITRAMFS_IMAGE_UUID"
+	else
+		return $ret
 	fi
 }
 
